package com.yang.mall.helper;

public class PageObject {

    private long total;
    private int page;
    private int pageSize;
    private double pageCount;

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public double getPageCount() {
        return pageCount;
    }

    public void setPageCount(double pageCount) {
        this.pageCount = pageCount;
    }

    public static PageObject page(long total, int page, int pageSize) {

        Double pageCount = Math.ceil(total * 1.0 / pageSize * 1.0);

        PageObject pageObject = new PageObject();
        pageObject.setTotal(total);
        pageObject.setPage(page);
        pageObject.setPageSize(pageSize);
        pageObject.setPageCount(pageCount);

        return pageObject;

    }

}
